﻿<%@ Page Title="Mobilhjulskift.dk - Indkøbskurv" Language="C#" MasterPageFile="~/Webshop/Webshop.master" AutoEventWireup="true" CodeBehind="Kurv.aspx.cs" Inherits="TireService.Website.Webshop.Kurv" %>

<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxCallbackPanel" TagPrefix="dx" %>
<%@ Register assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxPanel" tagprefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxLoadingPanel" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxCallback" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxPopupControl" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxRoundPanel" TagPrefix="dx" %>


<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="content" runat="server">

    <script type="text/javascript">

        function DeliveryOptionSelected(option) {
            rbtnDeliveryOptions.SetValue(option);

            if (rbtnDeliveryOptions.GetValue() == 0) {
                // Shipping delivery
                pMobileDelivery.SetVisible(false);
                pNormalDelivery.SetVisible(true);
            }
            if (rbtnDeliveryOptions.GetValue() == 1) {
                // Mobile delivery
                pMobileDelivery.SetVisible(true);
                pNormalDelivery.SetVisible(false);
            }
        }

        function SubscriptionSelected(subscriptionid) {
            // Set radiobutton
            rbtnSubscriptions.SetValue(subscriptionid);

            // Hide subscription details if show
            pcSubscriptionDetails.Hide();

            // Show popup - user has to confirm they understand the conditions
            pcSubscriptionSelected.Show();
        }

        function SubscriptionConfirmed() {

            pcSubscriptionSelected.Hide();

            // Add to shoppingcart
            callBackAddSubscription.PerformCallback(rbtnSubscriptions.GetValue()); 
        }

        function SubscriptionDeclined() {
            pcSubscriptionSelected.Hide();

            DeliveryOptionSelected(0);
        }

        function ShippingDeliverySelected(s, e) {
            callBackAddDelivery.PerformCallback(rbtnDelivery.GetValue());
        }

        // Function that runs when server postback done - add/select subscription
        function OnCallbackAddSubscriptionComplete(s, e) {
            // Update shoppingcart
            gvShoppingCart.PerformCallback();

            UpdateCheckOutForm(rbtnDeliveryOptions.GetValue());
        }

        // Function that runs when server postback done - add/select shipping delivery
        function OnCallbackAddDeliveryComplete(s, e) {
            // Update shoppingcart
            gvShoppingCart.PerformCallback();

            UpdateCheckOutForm(rbtnDeliveryOptions.GetValue());
        }

        // Function that updates GUI based on selected delivery method (Mobile or shipping)
        function UpdateCheckOutForm(selecteddeliveryoption) {
            pCustomerData.SetVisible(true);

            pDeliveryData.SetVisible(selecteddeliveryoption == 0);
        }

        // Function that runs when checkbox changed
        function DeliveryAddressChanged(s, e) {
            pDeliveryAddress.SetVisible(cbChangeDeliveryAddress.GetChecked());
        }

        // Function that runs when delivery options selected
        function DeliveryOptionsChanged(s, e) {
            txtDeliveryNote.SetVisible(rbtnShipmentDeliveryOptions.GetValue() == 5);
        }

        // Error happend
        function CallBackError(s, e) {
            // Hide loadingpanel while doing postback
            LoadingPanel.Hide();

            alert('Fejl opstod, venligst prøv igen');
        }

        // Function that checkout order
        function CheckOutOrder() {


            // Validate values
            txtName.Validate();
            txtAddress.Validate();
            txtZipCode.Validate();
            txtCity.Validate();
            txtPhone.Validate();
            txtEmail.Validate();

            var isFormValid = ASPxClientEdit.ValidateGroup("CheckOut");
            if (isFormValid) {

                var isFormCheckOutDelivery = true;
                // Used selected to change delivery address (only relevant if shipping delivery)
                if (cbChangeDeliveryAddress.GetChecked()) {
                    txtDeliveryName.Validate();
                    txtDeliveryAddress.Validate();
                    txtDeliveryZipCode.Validate();
                    txtDeliveryCity.Validate();

                    isFormCheckOutDelivery = ASPxClientEdit.ValidateGroup("CheckOutDelivery");
                }

                if (isFormCheckOutDelivery) {
                    // Type of delivery (private or business)
                    var isFormCheckOutDeliveryType = true;
                    // Options for delivery (where carrier can put products)
                    var isFormCheckOutDeliveryOptions = true;

                    var isFormCheckOutSubscriptionType = true;

                    // Check if customer has selected shipping method for delivery - validate afterwards
                    if (rbtnDeliveryOptions.GetValue() == 0) {
                        
                        rbtnDelivery.Validate();
                        isFormCheckOutDeliveryOptions = ASPxClientEdit.ValidateGroup("DeliveryType");

                        rbtnShipmentDeliveryOptions.Validate();
                        isFormCheckOutDeliveryOptions = ASPxClientEdit.ValidateGroup("CheckOutDeliveryOptions");

                    } else {
                        // Customer selected mobile solution

                        rbtnSubscriptions.Validate();
                        isFormCheckOutSubscriptionType = ASPxClientEdit.ValidateGroup("SubscriptionType");
                    }

                    if (isFormCheckOutDeliveryOptions & isFormCheckOutDeliveryOptions & isFormCheckOutSubscriptionType) {
                        var isFormCheckOutDeliveryOptionsNote = true;

                        // Check if delivery note must be made
                        if (rbtnShipmentDeliveryOptions.GetValue() == 5) {

                            txtDeliveryNote.Validate();

                            isFormCheckOutDeliveryOptionsNote = ASPxClientEdit.ValidateGroup("CheckOutDeliveryOptionsNote");
                        }

                        if (isFormCheckOutDeliveryOptionsNote) {
                            // Prepare input
                            // 0: Deliveryoptions (0: Mobile, 1: Shipping)
                            // 1: Subscription (1-6: SubscriptionId)
                            // 2: Delivery (0: Private, -1: Business)
                            // 3: Name
                            // 4: Address
                            // 5: ZipCode
                            // 6: City
                            // 7: Phone
                            // 8: Email
                            // 9: Change delivery address (true/false)
                            // 10: Delivery Name
                            // 11: Delivery Address
                            // 12: Delivery ZipCode
                            // 13: Delivery City
                            // 14: Shipment delivery options (0-5: Carport, ect.)
                            // 15: Delivery note
                            var input = rbtnDeliveryOptions.GetValue() + '|';
                            input += rbtnSubscriptions.GetValue() + '|';
                            input += rbtnDelivery.GetValue() + '|';
                            input += txtName.GetText() + '|';
                            input += txtAddress.GetText() + '|';
                            input += txtZipCode.GetText() + '|';
                            input += txtCity.GetText() + '|';
                            input += txtPhone.GetText() + '|';
                            input += txtEmail.GetText() + '|';
                            input += cbChangeDeliveryAddress.GetChecked() + '|';
                            input += txtDeliveryName.GetText() + '|';
                            input += txtDeliveryAddress.GetText() + '|';
                            input += txtDeliveryZipCode.GetText() + '|';
                            input += txtDeliveryCity.GetText() + '|';
                            input += rbtnShipmentDeliveryOptions.GetValue() + '|';
                            input += txtDeliveryNote.GetText();

                            // Show loadingpanel while doing postback
                            LoadingPanel.Show();

                            // Submit order
                            callbackCreateOrder.PerformCallback();
                        }
                    }
                }
            }
        }

        // Function that runs when server postback done - redirect to payment gateway
        function OnCallbackCreateOrderComplete(s, e) {
            // Hide loadingpanel while doing postback
            LoadingPanel.Hide();

            window.location = e.result;
        }


        


    </script>

    <dx:ASPxCallback ID="callBackAddSubscription" ClientInstanceName="callBackAddSubscription" runat="server" OnCallback="callBackAddSubscription_Callback">
        <ClientSideEvents CallbackError="CallBackError" CallbackComplete="OnCallbackAddSubscriptionComplete" />
    </dx:ASPxCallback>

    <dx:ASPxCallback ID="callBackAddDelivery" ClientInstanceName="callBackAddDelivery" runat="server" OnCallback="callBackAddDelivery_Callback">
        <ClientSideEvents CallbackError="CallBackError" CallbackComplete="OnCallbackAddDeliveryComplete" />
    </dx:ASPxCallback>

    <dx:ASPxCallback ID="callBackCreateOrder" ClientInstanceName="callBackCreateOrder" runat="server" OnCallback="callBackCreateOrder_Callback">
        <ClientSideEvents CallbackError="CallBackError" CallbackComplete="OnCallbackCreateOrderComplete" />
    </dx:ASPxCallback>

    <!-- Modal popup that fires when user selected subscription -->
    <dx:ASPxPopupControl ID="pcSubscriptionSelected" runat="server" CloseAction="None"
        Modal="True" PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter"
        ClientInstanceName="pcSubscriptionSelected" HeaderText="Bekræft valg af abonnement" EnableAnimation="False"
        EnableViewState="False" ClientIDMode="AutoID" EnableHotTrack="False">
        <LoadingPanelStyle ImageSpacing="5px">
        </LoadingPanelStyle>
        <ContentCollection>
            <dx:PopupControlContentControl ID="PopupControlContentControl1" runat="server">
                <dx:ASPxPanel ID="Panel1" runat="server" DefaultButton="btOK">
                    <PanelCollection>
                        <dx:PanelContent ID="PanelContent1" runat="server">
                            <asp:Panel ID="pNeedHelp" runat="server">
                                <table width="350px">
                                    <tr>
                                        <td colspan="2">
                                            <h1>
                                                Du har valgt vores mobile løsning</h1>
                                            <p class="normaltext">
                                                Forudsætningerne for at vi kan tilbyde dig denne løsning er
                                            
                                            <ul>
                                                <li>Du bor indenfor postnummer 1000-2999</li>
                                                <li>Fælge, hvor nye dæk skal monteres på, haves separat og sidder <u>ikke</u> monteret på din bil</li>
                                            </ul>
                                            
                                                Vælg nedenfor om du kan opfylde dette.
                                            </p>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td valign="top">
                                            <dx:ASPxButton ID="btnConfirm" runat="server" Text="Ja tak - jeg bekræfter" AutoPostBack="false" UseSubmitBehavior="False" Width="175px" Height="40px">
                                                <ClientSideEvents Click="function() { SubscriptionConfirmed(); }" />
                                            </dx:ASPxButton>
                                        </td>
                                        <td valign="top">
                                            <dx:ASPxButton ID="btnDecline" runat="server" Text="Nej desværre - venligst send dækkene til mig istedet" AutoPostBack="false" UseSubmitBehavior="False" Width="175px" Height="40px">
                                                <ClientSideEvents Click="function() { SubscriptionDeclined(); }" />
                                            </dx:ASPxButton>

                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="left">
                                            <%--<dx:ASPxButton ID="btnContinueSignup" runat="server" ClientIDMode="AutoID" 
                                                Text="Tilbage til bestilling" >
                                                <ClientSideEvents Click="function(s, e) { pcCancelSignup.Hide(); }" />
                                            </dx:ASPxButton>--%>
                                        </td>
                                        <td align="right">
                                            <%--<asp:LinkButton ID="lbtnCancelSignup" runat="server" 
                                                OnClick="lbtnCancelSignup_Click">Til startsiden</asp:LinkButton>        --%>
                                        </td>
                                    </tr>
                                </table>
                            </asp:Panel>
                        </dx:PanelContent>
                    </PanelCollection>
                </dx:ASPxPanel>
            </dx:PopupControlContentControl>
        </ContentCollection>
    </dx:ASPxPopupControl>

    <!-- Modal popup that fires when user select see more info on subscriptions -->
    <dx:ASPxPopupControl ID="pcSubscriptionDetails" runat="server" CloseAction="CloseButton"
        Modal="True" PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter"
        ClientInstanceName="pcSubscriptionDetails" HeaderText="Indhold af abonnementer" EnableAnimation="False"
        EnableViewState="False" ClientIDMode="AutoID" EnableHotTrack="False" Width="600px">
        <LoadingPanelStyle ImageSpacing="5px">
        </LoadingPanelStyle>
        <ContentCollection>
            <dx:PopupControlContentControl ID="PopupControlContentControl2" runat="server">
                <dx:ASPxPanel ID="ASPxPanel1" runat="server" DefaultButton="btOK">
                    <PanelCollection>
                        <dx:PanelContent ID="PanelContent2" runat="server">
                            <asp:Panel ID="Panel2" runat="server">
                               <table width="100%"  border="0" cellpadding="0" cellspacing="1">
			                        <tr>
				                        <td height="22" style="width: 347px">&nbsp;</td>
				                        <td width="85" align="center" class="normaltext"><b>Bronze</b></td>
				                        <td width="85" align="center" class="normaltext"><b>BronzePlus</b></td>
			                        </tr>
                                    <tr>
				                        <td height="22" class="normaltext" style="width: 347px">&nbsp;Udkørsel til dig (sommer/vinter skift)<br /></td>
				                        <td align="center" class="normaltext">
				                        <img alt="" src="../images/green_arrow.gif" width="14" height="14" /></td>
				                        <td align="center" class="normaltext">
				                        <img alt="" src="../images/green_arrow.gif" width="14" height="14" /></td>
			                        </tr>
                                    <tr>
				                        <td height="22" class="normaltext" style="width: 347px">&nbsp;Hjulskift (sommer/vinter skift)<br /></td>
				                        <td align="center" class="normaltext">
				                        <img alt="" src="../images/green_arrow.gif" width="14" height="14" /></td>
				                        <td align="center" class="normaltext">
				                        <img alt="" src="../images/green_arrow.gif" width="14" height="14" /></td>
			                        </tr>
                                    <tr>
				                        <td height="22" class="normaltext" style="width: 347px">&nbsp;Opbevaring af hjul<br /></td>
				                        <td align="center" class="normaltext">
				                        <img alt="" src="../images/green_arrow.gif" width="14" height="14" /></td>
				                        <td align="center" class="normaltext">
				                        <img alt="" src="../images/green_arrow.gif" width="14" height="14" /></td>
			                        </tr>
                                    <tr>
				                        <td height="22" class="normaltext" style="width: 432px">&nbsp;Kontrol for slidtage, kæring og lufttryk</td>
				                        <td align="center" class="normaltext">
				                        <img alt="" src="../images/green_arrow.gif" width="14" height="14" /></td>
                                        <td align="center" class="normaltext">
				                        <img alt="" src="../images/green_arrow.gif" width="14" height="14" /></td>
			                        </tr>
                                    <tr>
				                        <td height="22" class="normaltext" style="width: 432px">&nbsp;Login 
				                        til vores system hvor slidtage mm. kan følges</td>
				                        <td align="center" class="normaltext">
				                        <img alt="" src="../images/green_arrow.gif" width="14" height="14" /></td>
                                        <td align="center" class="normaltext">
				                        <img alt="" src="../images/green_arrow.gif" width="14" height="14" /></td>
			                        </tr>
                                    <tr>
				                        <td height="22" class="normaltext" style="width: 432px">&nbsp;Afbalancering af hjul (hos os)</td>
				                        <td align="center" class="normaltext">
				                        <img alt="" src="../images/red_sign.gif" width="16" height="16" /></td>
				                        <td align="center" class="normaltext">
				                        <img alt="" src="../images/green_arrow.gif" width="14" height="14" /></td>
			                        </tr>
                                    <tr>
				                        <td height="22" class="bg9" style="width: 432px">
                                            <b>&nbsp;Pris pr. gang - halvårlig (incl. moms)</b>
                                        </td>
				                        <td align="center" class="bg9"><b>599,-</b></td>
				                        <td align="center" class="bg9"><b>724,-</b></td>
			                        </tr>
			                        <tr>
				                        <td height="22" style="width: 432px">&nbsp;</td>
				                        <td align="center">
                                            <dx:ASPxButton ID="btnBronzeHalf" runat="server" Text="Vælg" AutoPostBack="false">
                                                <ClientSideEvents Click="function() { SubscriptionSelected(5); }" />
                                            </dx:ASPxButton>
                                        </td>
				                        <td align="center">
                                            <dx:ASPxButton ID="btnBronzePlusHalf" runat="server" Text="Vælg" AutoPostBack="false">
                                                <ClientSideEvents Click="function() { SubscriptionSelected(1); }" />
                                            </dx:ASPxButton>
                                        </td>
			                        </tr>
                                    <tr>
				                        <td height="22" class="bg9" style="width: 432px">
                                            <b>&nbsp;Årlig abonnement - dækker 2 skift (incl. moms)</b>
                                        </td>
				                        <td align="center" class="bg9"><b>1099,-</b></td>
				                        <td align="center" class="bg9"><b>1349,-</b></td>
			                        </tr>
			                        <tr>
				                        <td height="22" style="width: 432px">&nbsp;</td>
				                        <td align="center">
                                            <dx:ASPxButton ID="btnBronze" runat="server" Text="Vælg" AutoPostBack="false">
                                                <ClientSideEvents Click="function() { SubscriptionSelected(1); }" />
                                            </dx:ASPxButton>
                                        </td>
				                        <td align="center">
                                            <dx:ASPxButton ID="btnBronzePlus" runat="server" Text="Vælg" AutoPostBack="false">
                                                <ClientSideEvents Click="function() { SubscriptionSelected(6); }" />
                                            </dx:ASPxButton>
                                        </td>
			                        </tr>
		                        </table>
                            </asp:Panel>
                        </dx:PanelContent>
                    </PanelCollection>
                </dx:ASPxPanel>
            </dx:PopupControlContentControl>
        </ContentCollection>
    </dx:ASPxPopupControl>

    <h1>Indkøbskurv</h1>
    <dx:ASPxGridView ID="gvShoppingCart" runat="server" ClientInstanceName="gvShoppingCart" Width="100%" Font-Size="Larger"
        KeyFieldName="ItemId" AutoGenerateColumns="False" EnableCallBacks="True" OnCustomCallback="gvShoppingCart_CustomCallback">
        <Styles AlternatingRow-Font-Size="Larger" Row-Font-Size="Larger" Header-Font-Size="Larger"></Styles>
        <SettingsLoadingPanel Text="Henter&amp;hellip;" />
        <SettingsText EmptyDataRow="Ingen produkter valgt" />
        <SettingsPager AlwaysShowPager="False" PageSize="30" Position="Bottom">
            <Summary AllPagesText="Sider: {0} - {1} ({2} produkter)" Text="Side {0} af {1} ({2} produkter)" />
        </SettingsPager>
        <SettingsBehavior AllowSort="false" ConfirmDelete="false" AllowGroup="false" AllowDragDrop="false" />
        <Columns>
            <dx:GridViewDataColumn FieldName="SubscriptionId" Visible="false" VisibleIndex="0"
                Caption="SubscriptionId">
            </dx:GridViewDataColumn>
            <dx:GridViewDataTextColumn FieldName="Description" VisibleIndex="1" Caption="Produkt">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataSpinEditColumn FieldName="UnitPrice" VisibleIndex="2" Caption="Enhedspris">
                <PropertiesSpinEdit DisplayFormatString="c"></PropertiesSpinEdit>
            </dx:GridViewDataSpinEditColumn>
            <dx:GridViewDataColumn FieldName="Quantity" VisibleIndex="3" Caption="Antal">
            </dx:GridViewDataColumn>                                  
            <dx:GridViewDataSpinEditColumn FieldName="TotalPrice" VisibleIndex="3" Caption="Total pris">
                <PropertiesSpinEdit DisplayFormatString="c"></PropertiesSpinEdit>
            </dx:GridViewDataSpinEditColumn>
        </Columns>
        <Settings ShowFooter="True" />
        <TotalSummary>
            <dx:ASPxSummaryItem FieldName="TotalPrice" SummaryType="Sum" />
        </TotalSummary>
    </dx:ASPxGridView>
    <dx:ASPxCallbackPanel ID="callbackCheckOutform" ClientInstanceName="callbackCheckOutform" runat="server" Width="100%">
        <PanelCollection>
            <dx:PanelContent>
                <h4>Vælg om du ønsker Mobil monteringsløsning, eller om du selv ønsker at stå for det praktiske</h4>
                <dx:ASPxRadioButtonList runat="server" ID="rbtnDeliveryOptions" ClientInstanceName="rbtnDeliveryOptions" AutoPostBack="false">
                    <ClientSideEvents SelectedIndexChanged="function(s, e) { DeliveryOptionSelected(rbtnDeliveryOptions.GetValue()); }" />
                    <Items>
                        <dx:ListEditItem Value="1" Text="Mobil montering" />
                        <dx:ListEditItem Value="0" Text="Levering af dæk" />
                    </Items>
                </dx:ASPxRadioButtonList>
                <hr />
                <dx:ASPxPanel ID="pMobileDelivery" ClientInstanceName="pMobileDelivery" runat="server" Width="100%" ClientVisible="false">
                    <PanelCollection>
                        <dx:PanelContent>
                            <h3>Mobil montering - undgå at rør en finger, vi kommer og montere hos dig!</h3>
                            <p class="normaltext">
                            Med i prisen er et bronze abonnement som også indeholder opbevaring af dine øvrige hjul hos os.<br />
                            <br />
                            Vælg mellem årlig eller halvårlig abonnementer (<a href="#" onclick="pcSubscriptionDetails.Show();">Vis mig indhold af abonnementer</a>)
                            </p>
                            <dx:ASPxRadioButtonList runat="server" ID="rbtnSubscriptions" ClientInstanceName="rbtnSubscriptions" AutoPostBack="false">
                                <ClientSideEvents SelectedIndexChanged="function() { SubscriptionSelected(rbtnSubscriptions.GetValue()); }" />
                                <Items>
                                    <dx:ListEditItem Value="1" Text="Bronze, årlig - Pris: 1099kr" />
                                    <dx:ListEditItem Value="5" Text="Bronze, halvårlig - Pris: 599kr" />
                                    <dx:ListEditItem Value="6" Text="BronzePlus, årlig - Pris: 1349kr" />
                                    <dx:ListEditItem Value="7" Text="BronzePlus, halvårlig - Pris: 724kr" />
                                </Items>
                                <ValidationSettings ValidationGroup="SubscriptionType" RequiredField-ErrorText="Vælg abonnement"
                                    ErrorDisplayMode="ImageWithTooltip" RequiredField-IsRequired="true">
                                </ValidationSettings>
                            </dx:ASPxRadioButtonList>
                        </dx:PanelContent>
                    </PanelCollection>
                </dx:ASPxPanel>
                <dx:ASPxPanel ID="pNormalDelivery" ClientInstanceName="pNormalDelivery" runat="server" Width="100%" ClientVisible="false">
                    <PanelCollection>
                        <dx:PanelContent>
                            <h3>Levering af dæk</h3>
                            Vælg leveringsmetode.<br />
                            <dx:ASPxRadioButtonList runat="server" ID="rbtnDelivery" ClientInstanceName="rbtnDelivery" AutoPostBack="false">
                                <ClientSideEvents SelectedIndexChanged="function(s, e) { ShippingDeliverySelected(s, e); }" />
                                <Items>
                                    <dx:ListEditItem Value="0" Text="Privat levering: Levering til privatadresse - 199kr" />
                                    <dx:ListEditItem Value="-1" Text="Erhvervslevering: Levering til erhvervsadresse - 99kr" />
                                </Items>
                                <ValidationSettings ValidationGroup="DeliveryType" RequiredField-ErrorText="Vælg leveringsmetode"
                                    ErrorDisplayMode="ImageWithTooltip" RequiredField-IsRequired="true">
                                </ValidationSettings>
                            </dx:ASPxRadioButtonList>
                        </dx:PanelContent>
                    </PanelCollection>
                </dx:ASPxPanel>
                <dx:ASPxPanel ID="pCustomerData" ClientInstanceName="pCustomerData" runat="server" Width="100%" ClientVisible="false">
                    <PanelCollection>
                        <dx:PanelContent>
                            <hr />
                            <h3>Kundeoplysninger</h3>
                            <table>
                                <tr>
                                    <td>
                                        Navn
                                        <dx:ASPxTextBox ID="txtname" ClientInstanceName="txtName" runat="server" Width="170px">
                                            <ValidationSettings ValidationGroup="CheckOut" RequiredField-IsRequired="true" RequiredField-ErrorText="Navn skal udfyldes"
                                                ErrorDisplayMode="ImageWithTooltip">
                                            </ValidationSettings>
                                        </dx:ASPxTextBox>
                                    </td>
                                    <td>
                                        Addresse
                                        <dx:ASPxTextBox ID="txtAddress" ClientInstanceName="txtAddress" runat="server" Width="170px">
                                            <ValidationSettings ValidationGroup="CheckOut" RequiredField-ErrorText="Adresse skal udfyldes"
                                                ErrorDisplayMode="ImageWithTooltip" RequiredField-IsRequired="true">
                                            </ValidationSettings>
                                        </dx:ASPxTextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Postnr
                                        <dx:ASPxTextBox ID="txtZipCode" ClientInstanceName="txtZipCode" runat="server" Width="170px">
                                            <ValidationSettings ValidationGroup="CheckOut" RequiredField-IsRequired="true" RequiredField-ErrorText="Postnr skal udfyldes"
                                                RegularExpression-ValidationExpression="\d{4}" RegularExpression-ErrorText="Postnr ikke gyldigt"
                                                ErrorDisplayMode="ImageWithTooltip" >
                                            </ValidationSettings>
                                        </dx:ASPxTextBox>
                                    </td>
                                    <td>
                                        By
                                        <dx:ASPxTextBox ID="txtCity" ClientInstanceName="txtCity" runat="server" Width="170px">
                                            <ValidationSettings ValidationGroup="CheckOut" RequiredField-ErrorText="By skal udfyldes"
                                                ErrorDisplayMode="ImageWithTooltip" RequiredField-IsRequired="true">
                                            </ValidationSettings>
                                        </dx:ASPxTextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Telefon
                                        <dx:ASPxTextBox ID="txtPhone" ClientInstanceName="txtPhone" runat="server" Width="170px">
                                            <ValidationSettings ValidationGroup="CheckOut" RequiredField-IsRequired="true" ErrorDisplayMode="ImageWithTooltip"
                                                RegularExpression-ValidationExpression="\d{8}" RegularExpression-ErrorText="Telefon ikke gyldigt" />
                                        </dx:ASPxTextBox>
                                    </td>
                                    <td>
                                        Email
                                        <dx:ASPxTextBox ID="txtEmail" ClientInstanceName="txtEmail" runat="server" Width="170px">
                                            <ValidationSettings RegularExpression-ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                                                ErrorDisplayMode="ImageWithTooltip" RegularExpression-ErrorText="Email ikke gyldig"
                                                RequiredField-IsRequired="true" RequiredField-ErrorText="Venligst udfyld email adresse"
                                                ValidationGroup="CheckOut">
                                            </ValidationSettings>
                                        </dx:ASPxTextBox>
                                    </td>
                                </tr>
                            </table>
                        </dx:PanelContent>
                    </PanelCollection>
                </dx:ASPxPanel>
                <dx:ASPxPanel ID="pDeliveryData" ClientInstanceName="pDeliveryData" runat="server" Width="100%" ClientVisible="false">
                    <PanelCollection>
                        <dx:PanelContent>
                            <hr />
                            <h3>Leveringsoplysninger</h3>
                            <dx:ASPxCheckBox ID="cbChangeDeliveryAddress" ClientInstanceName="cbChangeDeliveryAddress" runat="server" Text="Skift leveringsadresse">
                                <ClientSideEvents CheckedChanged="function(s, e) { DeliveryAddressChanged(s, e); }" />
                            </dx:ASPxCheckBox>
                            <dx:ASPxPanel ID="pDeliveryAddress" ClientInstanceName="pDeliveryAddress" runat="server" Width="100%" ClientVisible="false">
                                <PanelCollection>
                                    <dx:PanelContent>
                                        <h4>Leveringsadresse (Udfyldes kun hvis leveringsadressen er forskellig fra faktureringsadressen)</h4>
                                        <table>
                                            <tr>
                                                <td>
                                                    Navn
                                                    <dx:ASPxTextBox ID="txtDeliveryName" ClientInstanceName="txtDeliveryName" runat="server" Width="170px">
                                                        <ValidationSettings ValidationGroup="CheckOutDelivery" RequiredField-IsRequired="true" RequiredField-ErrorText="Navn skal udfyldes"
                                                            ErrorDisplayMode="ImageWithTooltip">
                                                        </ValidationSettings>
                                                    </dx:ASPxTextBox>
                                                </td>
                                                <td>
                                                    Addresse
                                                    <dx:ASPxTextBox ID="txtDeliveryAddress" ClientInstanceName="txtDeliveryAddress" runat="server" Width="170px">
                                                        <ValidationSettings ValidationGroup="CheckOutDelivery" RequiredField-ErrorText="Adresse skal udfyldes"
                                                            ErrorDisplayMode="ImageWithTooltip" RequiredField-IsRequired="true">
                                                        </ValidationSettings>
                                                    </dx:ASPxTextBox>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    Postnr
                                                    <dx:ASPxTextBox ID="txtDeliveryZipCode" ClientInstanceName="txtDeliveryZipCode" runat="server" Width="170px">
                                                        <ValidationSettings ValidationGroup="CheckOutDelivery" RequiredField-IsRequired="true" RequiredField-ErrorText="Postnr skal udfyldes"
                                                            RegularExpression-ValidationExpression="\d{4}" RegularExpression-ErrorText="Postnr ikke gyldigt"
                                                            ErrorDisplayMode="ImageWithTooltip" >
                                                        </ValidationSettings>
                                                    </dx:ASPxTextBox>
                                                </td>
                                                <td>
                                                    By
                                                    <dx:ASPxTextBox ID="txtDeliveryCity" ClientInstanceName="txtDeliveryCity" runat="server" Width="170px">
                                                        <ValidationSettings ValidationGroup="CheckOutDelivery" RequiredField-ErrorText="By skal udfyldes"
                                                            ErrorDisplayMode="ImageWithTooltip" RequiredField-IsRequired="true">
                                                        </ValidationSettings>
                                                    </dx:ASPxTextBox>
                                                </td>
                                            </tr>
                                        </table>

                                    </dx:PanelContent>
                                </PanelCollection>
                            </dx:ASPxPanel>
                            <h4>Hvis ingen træffes på adressen må varerne...</h4>
                            <dx:ASPxRadioButtonList runat="server" ID="rbtnShipmentDeliveryOptions" ClientInstanceName="rbtnShipmentDeliveryOptions" AutoPostBack="false">
                                <ClientSideEvents SelectedIndexChanged="function(s, e) { DeliveryOptionsChanged(s, e); }" />
                                <Items>
                                    <dx:ListEditItem Value="0" Text="Stilles ved hoveddør" />
                                    <dx:ListEditItem Value="1" Text="Stilles i carport / garage" />
                                    <dx:ListEditItem Value="2" Text="Stilles i skur" />
                                    <dx:ListEditItem Value="3" Text="Stilles i baghaven" />
                                    <dx:ListEditItem Value="4" Text="Tages med retur til fragtcentral, så afhenter jeg der" />
                                    <dx:ListEditItem Value="5" Text="Andet (Noter nedenfor)" />
                                </Items>
                                <ValidationSettings ValidationGroup="CheckOutDeliveryOptions" RequiredField-ErrorText="Angiv løsning der passer dig bedst"
                                    ErrorDisplayMode="ImageWithTooltip" RequiredField-IsRequired="true">
                                </ValidationSettings>
                            </dx:ASPxRadioButtonList>
                            <br />
                            <dx:ASPxTextBox ID="txtDeliveryNote" ClientInstanceName="txtDeliveryNote" NullText="Angiv note omkring levering" runat="server" Width="200px" ClientVisible="false">
                                <ValidationSettings ValidationGroup="CheckOutDeliveryOptionsNote" RequiredField-ErrorText="Angiv note"
                                    ErrorDisplayMode="ImageWithTooltip" RequiredField-IsRequired="true">
                                </ValidationSettings>
                            </dx:ASPxTextBox>
                        </dx:PanelContent>
                    </PanelCollection>
                </dx:ASPxPanel>
                <hr />
                <div style="text-align:center">
                    Læs vores betalings- og leveringsbetingelser her: <a href="~/HtmlTemplates/Betingelser.pdf" id="lnkPaymentTerms" runat="server" target="_blank">Link</a><br />
                    <br />
                    <dx:ASPxCheckBox ID="cbApproveTermns" ClientInstanceName="cbApproveTermns" AutoPostBack="false"
                        Text="Jeg har læst og accepteret mobilhjulskift.dk's salgs- og leveringsbetingelser" runat="server">
                        <ClientSideEvents CheckedChanged="function(s, e) { if (cbApproveTermns.GetChecked() == true) { btnCheckOut.SetEnabled(true) } else { btnCheckOut.SetEnabled(false) } }" />
                    </dx:ASPxCheckBox>
                    <dx:ASPxButton ID="btnCheckOut" ClientInstanceName="btnCheckOut" runat="server" ClientEnabled="false" Width="200px" Height="30px" Font-Size="Large"
                        Text="Gennemfør ordre og gå til betaling" AutoPostBack="False" UseSubmitBehavior="False">
                        <ClientSideEvents Click="function(s, e) { CheckOutOrder(); }" />
                    </dx:ASPxButton>
                </div>

            </dx:PanelContent>
        </PanelCollection>
    </dx:ASPxCallbackPanel>

    <%--<dx:ASPxGridView ID="gvShoppingCart" ClientInstanceName="gvShoppingCart" runat="server" Width="100%" KeyFieldName="ItemId" AutoGenerateColumns="false">
        <Templates>
            <PreviewRow>
                <table width="100%">
                    <tr>
                        <td valign="top" style="width:320px">
                            <b><%# Eval("Description")%></b>
                        </td>
                        <td>
                            <b><%# Eval("UnitPrice")%></b>
                        </td>
                        <td>
                            <b><%# Eval("Quantity")%></b>
                        </td>
                        <td>
                            <b><%# Eval("TotalPrice")%></b>
                        </td>
                    </tr>
                </table>
            </PreviewRow>
        </Templates>
        <Settings ShowPreview="true" ShowGroupPanel="false" />
        <SettingsPager PageSize="30" />

    </dx:ASPxGridView>--%>


</asp:Content>
